﻿<UserControl xmlns:Controls="clr-namespace:Daytimer.Controls" x:Class="Daytimer.Controls.DatePickerControl"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="23"
		d:DesignWidth="300" BorderBrush="#FFABADB3" BorderThickness="1" Background="{DynamicResource White}">
	<UserControl.Resources>
		<Controls:NegativeConverter x:Key="NegativeConverter" />
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>
		<Grid.Resources>
			<Style TargetType="TextBlock">
				<Setter Property="Foreground" Value="#FF9B9AB3" />
				<Setter Property="Margin" Value="0" />
				<Setter Property="VerticalAlignment" Value="Center" />
			</Style>
		</Grid.Resources>
		<TextBlock x:Name="PART_Watermark" Text="Select a date" Padding="3,0,0,0" VerticalAlignment="Center"
				Foreground="#FF808080" />
		<TextBox x:Name="PART_Text" BorderThickness="0" VerticalContentAlignment="Center" Background="{x:Null}"
				TextChanged="PART_Text_TextChanged" PreviewKeyDown="PART_Text_PreviewKeyDown"
				PreviewLostKeyboardFocus="PART_Text_PreviewLostKeyboardFocus" />
		<ToggleButton x:Name="PART_Button" Grid.Column="1" Focusable="False" HorizontalAlignment="Stretch"
				VerticalAlignment="Stretch" Width="26" Checked="PART_Button_Checked"
				PreviewMouseLeftButtonDown="PART_Button_PreviewMouseLeftButtonDown">
			<ToggleButton.Template>
				<ControlTemplate TargetType="ToggleButton">
					<Grid>
						<Border BorderThickness="1,0,0,0">
							<Border.Background>
								<SolidColorBrush x:Name="bg" Color="Transparent" />
							</Border.Background>
							<Border.BorderBrush>
								<SolidColorBrush x:Name="border" Color="Transparent" />
							</Border.BorderBrush>
							<Image
									Source="pack://application:,,,/Daytimer.Images;component/Images/newappointment_sml.png"
									Stretch="None" />
						</Border>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Normal" />
								<VisualState x:Name="MouseOver">
									<Storyboard>
										<ColorAnimationUsingKeyFrames Storyboard.TargetName="bg"
												Storyboard.TargetProperty="Color">
											<EasingColorKeyFrame Value="#FFCCE4F5" KeyTime="0" />
										</ColorAnimationUsingKeyFrames>
										<ColorAnimationUsingKeyFrames Storyboard.TargetName="border"
												Storyboard.TargetProperty="Color">
											<EasingColorKeyFrame Value="#FF93BFDF" KeyTime="0" />
										</ColorAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Pressed">
									<Storyboard>
										<ColorAnimationUsingKeyFrames Storyboard.TargetName="bg"
												Storyboard.TargetProperty="Color">
											<EasingColorKeyFrame Value="#FF92C0E0" KeyTime="0" />
										</ColorAnimationUsingKeyFrames>
										<ColorAnimationUsingKeyFrames Storyboard.TargetName="border"
												Storyboard.TargetProperty="Color">
											<EasingColorKeyFrame Value="#FF2D8DD2" KeyTime="0" />
										</ColorAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Checked">
									<Storyboard>
										<ColorAnimationUsingKeyFrames Storyboard.TargetName="bg"
												Storyboard.TargetProperty="Color">
											<EasingColorKeyFrame Value="#FF92C0E0" KeyTime="0" />
										</ColorAnimationUsingKeyFrames>
										<ColorAnimationUsingKeyFrames Storyboard.TargetName="border"
												Storyboard.TargetProperty="Color">
											<EasingColorKeyFrame Value="#FF2D8DD2" KeyTime="0" />
										</ColorAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Disabled" />
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
					</Grid>
				</ControlTemplate>
			</ToggleButton.Template>
		</ToggleButton>
		<Popup x:Name="PART_Popup" Placement="Right" AllowsTransparency="True" PopupAnimation="Fade"
				VerticalOffset="{Binding ActualHeight, ElementName=PART_Text, Mode=OneWay}"
				HorizontalOffset="{Binding ActualWidth, Converter={StaticResource NegativeConverter}, ElementName=PART_Border, Mode=OneWay}"
				StaysOpen="False" Closed="PART_Popup_Closed">
			<Border x:Name="PART_Border" BorderThickness="1" BorderBrush="#FFA5ACB5" Width="200" Height="250"
					Background="White">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition />
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="*" />
						<RowDefinition Height="40" />
					</Grid.RowDefinitions>
					<Controls:CalendarControl x:Name="PART_Calendar" Grid.ColumnSpan="2"
							OnSelectedDateChangedEvent="PART_Calendar_OnSelectedDateChangedEvent" />
					<!-- Footer -->
					<Line X2="1" Stretch="Fill" StrokeThickness="1" Stroke="#FFF5F5F5" Grid.Row="1" Grid.ColumnSpan="2"
							VerticalAlignment="Top" />
					<Button x:Name="PART_Today" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"
							Content="_Today" Click="PART_Today_Click" />
					<Button x:Name="PART_None" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center"
							VerticalAlignment="Center" Content="_None" Click="PART_None_Click" />
				</Grid>
			</Border>
		</Popup>
	</Grid>
</UserControl>
